<template>
  <el-button :type="type" :icon="icon" :loading="loading" v-if="hasPermission()" size="small">
    <slot />
  </el-button>
  <!-- <el-link :type="type" v-if="link && hasPermission()">
      <slot />
    </el-link> -->
</template>
<script>
export default {
  name: "AuthButton",
  props: {
    uid: {
      type: [String, Number],
      default: "",
    },
    type: {
      type: [String, Number],
      default: "default",
    },
    link: {
      type: Boolean,
      default: false,
    },
    icon:{
      type:String,
      default:''
    },
    loading:{
      type:Boolean,
      default:false
    }
  },
  data() {
    return {};
  },
  mounted() {
  },
  methods: {
    // 判断是否有权限
    hasPermission() {
      let id = this.uid;
      let list = this.$store.state.currentPermission||[];
      let idx = list.findIndex((k) => k.id == id);
      if (idx < 0) {
        return false;
      } else {
        return true;
      }
    },
  },
};
</script>
<style lang="scss" scoped>
</style>